package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.pojo.OrderGoods;
import com.cskaoyan.bean.wx.order.bo.AddOrderBo;
import com.cskaoyan.bean.wx.order.bo.CommentBo;
import com.cskaoyan.bean.wx.order.bo.PageInfoBo;
import com.cskaoyan.bean.wx.order.vo.OrderDetailVo;
import com.cskaoyan.bean.wx.order.vo.OrderIdVo;
import com.cskaoyan.bean.wx.order.vo.OrderListVo;
import com.cskaoyan.service.wx.WxOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Name : WxOrderController.java
 * @Time : 2021/8/15 14:41
 * @Author : Xfeng
 * @Software : IntelliJ IDEA
 */

@RestController
@RequestMapping("wx/order")
public class WxOrderController {

    @Autowired
    WxOrderService wxOrderService;

    @RequestMapping("list")
    public BaseRespVo list(Integer showType, PageInfoBo pageInfoBo){
        OrderListVo orderListVo = wxOrderService.list(showType, pageInfoBo);
        return BaseRespVo.ok(orderListVo);
    }

    @RequestMapping("detail")
    public BaseRespVo detail(Integer orderId){
        OrderDetailVo detail = wxOrderService.detail(orderId);
        return BaseRespVo.ok(detail);
    }

    @RequestMapping("cancel")
    public BaseRespVo cancel(@RequestBody OrderGoods orderGoods){
        wxOrderService.cancel(orderGoods);
        return BaseRespVo.ok();
    }

    @RequestMapping("refund")
    public BaseRespVo refund(@RequestBody OrderGoods orderGoods){
        wxOrderService.refund(orderGoods);
        return BaseRespVo.ok();
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody OrderGoods orderGoods){
        wxOrderService.delete(orderGoods);
        return BaseRespVo.ok();
    }

    @RequestMapping("confirm")
    public BaseRespVo confirm(@RequestBody OrderGoods orderGoods){
        wxOrderService.confirm(orderGoods);
        return BaseRespVo.ok();
    }

    @RequestMapping("goods")
    public BaseRespVo goods(Integer orderId, Integer goodsId){
        OrderGoods goods = wxOrderService.goods(orderId, goodsId);
        return BaseRespVo.ok(goods);
    }

    @RequestMapping("comment")
    public BaseRespVo comment(@RequestBody CommentBo commentBo){
        wxOrderService.comment(commentBo);
        return BaseRespVo.ok();
    }

    @RequestMapping("submit")
    public BaseRespVo submit(@RequestBody AddOrderBo addOrderBo){
        OrderIdVo submit = wxOrderService.submit(addOrderBo);
        return BaseRespVo.ok(submit);
    }

    @RequestMapping("prepay")
    public BaseRespVo prepay(@RequestBody OrderIdVo orderIdVo){
        //更改unpaid_value
        wxOrderService.prepay(orderIdVo);
        return BaseRespVo.ok();
    }
}
